Only handle key bindings for scrolling if the scrollbars are visible.
authorMatthias Clasen <mclasen@redhat.com>
Tue, 2 Jan 2007 07:07:09 +0000 (07:07 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 2 Jan 2007 07:07:09 +0000 (07:07 +0000)
2007-01-01  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkscrolledwindow.h:
        * gtk/gtkscrolledwindow.c: Only handle key bindings
        for scrolling if the scrollbars are visible.
        (#340135, Christian Persch)

svn path=/trunk/; revision=17012

ChangeLog
gtk/gtkscrolledwindow.c
gtk/gtkscrolledwindow.h

index a08bede90bad343e3aa4419013402f24db78b548..8a239ce1374bf550540e1960c0c3dd52c616e0a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-01-01  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkscrolledwindow.h:
+       * gtk/gtkscrolledwindow.c: Only handle key bindings
+       for scrolling if the scrollbars are visible.
+       (#340135, Christian Persch)
+
 2007-01-01  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtktextview.c (gtk_text_view_scroll_hpages):
index d9ab546ef031d7dcfef6e2f23344a71232b464c1..3a15b5106e63c200f8666d17b355e20f73331f6a 100644 (file)
@@ -131,7 +131,7 @@ static void gtk_scrolled_window_forall             (GtkContainer           *cont
                                                    gboolean                include_internals,
                                                    GtkCallback             callback,
                                                    gpointer                callback_data);
-static void gtk_scrolled_window_scroll_child       (GtkScrolledWindow      *scrolled_window,
+static gboolean gtk_scrolled_window_scroll_child   (GtkScrolledWindow      *scrolled_window,
                                                    GtkScrollType           scroll,
                                                    gboolean                horizontal);
 static void gtk_scrolled_window_move_focus_out     (GtkScrolledWindow      *scrolled_window,
@@ -311,8 +311,8 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class)
                   G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                   G_STRUCT_OFFSET (GtkScrolledWindowClass, scroll_child),
                   NULL, NULL,
-                  _gtk_marshal_VOID__ENUM_BOOLEAN,
-                  G_TYPE_NONE, 2,
+                  _gtk_marshal_BOOLEAN__ENUM_BOOLEAN,
+                  G_TYPE_BOOLEAN, 2,
                   GTK_TYPE_SCROLL_TYPE,
                  G_TYPE_BOOLEAN);
   signals[MOVE_FOCUS_OUT] =
@@ -1000,7 +1000,7 @@ gtk_scrolled_window_forall (GtkContainer *container,
     }
 }
 
-static void
+static gboolean
 gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window,
                                  GtkScrollType      scroll,
                                  gboolean           horizontal)
@@ -1050,9 +1050,13 @@ gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window,
       break;
     default:
       g_warning ("Invalid scroll type %u for GtkSpinButton::change-value", scroll);
-      return;
+      return FALSE;
     }
 
+  if ((horizontal && (!scrolled_window->hscrollbar || !scrolled_window->hscrollbar_visible)) ||
+      (!horizontal && (!scrolled_window->vscrollbar || !scrolled_window->vscrollbar_visible)))
+    return FALSE;
+
   if (horizontal)
     {
       if (scrolled_window->hscrollbar)
@@ -1096,7 +1100,11 @@ gtk_scrolled_window_scroll_child (GtkScrolledWindow *scrolled_window,
       value = CLAMP (value, adjustment->lower, adjustment->upper - adjustment->page_size);
       
       gtk_adjustment_set_value (adjustment, value);
+
+      return TRUE;
     }
+
+  return FALSE;
 }
 
 static void
index 38e674ea1ee885644f59fbbd448cac1af4bbd20e..c9668f3750a34ce740a928686d8654d7cc5e8754 100644 (file)
@@ -81,9 +81,9 @@ struct _GtkScrolledWindowClass
    * no horizontal/vertical variants for GTK_SCROLL_START/END,
    * so we have to add an additional boolean flag.
    */
-  void (*scroll_child) (GtkScrolledWindow *scrolled_window,
-                       GtkScrollType      scroll,
-                       gboolean           horizontal);
+  gboolean (*scroll_child) (GtkScrolledWindow *scrolled_window,
+                           GtkScrollType      scroll,
+                           gboolean           horizontal);
 
   void (* move_focus_out) (GtkScrolledWindow *scrolled_window,
                           GtkDirectionType   direction);